package com.xiexie.order.controller;

import com.xiexie.order.feign.StockFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Description
 * @Date 2022-04-07 14:46
 * @Author xie
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private StockFeignService stockFeignService;

    @RequestMapping("/add")
    public String add() {
        System.out.println("下单成功");

        //String msg = restTemplate.getForObject("http://localhost:8011/stock/reduct", String.class);

        //String msg = restTemplate.getForObject("http://stock-server/stock/reduct", String.class);

        String reduct = stockFeignService.reduct();
        String get = stockFeignService.get(1);

        return "Hello order add " + reduct + get;
    }
}
